﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using HGZP.BLL;
using HGZP.Model;
using HGZP.PLL;
using System.Data;
namespace SZCB.admin.Contry
{
    public partial class AddCountry : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 提交按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            CCountryBLL myCCountryBLL = new CCountryBLL();
            DataTable dt = myCCountryBLL.F02_SelectHaveWhere("sName = '" + txtName.Text + "'");
            if (dt.Rows.Count > 0)
            {
                string strErrmessage = "该国家已添加";
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + strErrmessage + "');</script>");
                return;
            }
            CCountry myCCountry = new CCountry();
            myCCountry.sGuid = MyFunction.GetNewGuid();
            myCCountry.sName = txtName.Text;
            myCCountry.sCode = "";
            if (!myCCountryBLL.F_Insert(myCCountry))
            {
                string strErrmessage = "添加国家失败";
                Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + strErrmessage + "');</script>");
                return;
            }

        }

    }
}